package WaiBao;

import java.util.Arrays;

public class JiXia {
    public static void main(String[] args) {
        String[] name = {"张换发(班长)","李志杰(体育委员)", "小李(学习委员)","王志文(文艺委员)", "王劲松", "鲁易坤", "李德宝", "吴藏名", "李村", "张德彪", "程咬金", "典韦",
                "李贺", "白居易", "欧阳修", "司马懿", "司马昭", "李渡", "王东", "江即为", "徐的梦", "李志豪", "李晨器", "李梦华", "张大福", "李志宝", "张紧着", "爱媛橙",
                "橙子", "冀霞(学生)"};//考生本人: 冀霞(学生)
        int[] age = {21, 19, 20, 19, 18, 21, 19, 21, 20, 20, 18, 19, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 19};//最后一位：考生年龄:19

        double[] weixing1 = {87, 91, 76, 79, 77, 69, 88, 89, 81, 80, 91, 87, 85, 74, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 96};
        double[] weixing2 = {89, 84, 96, 90, 78, 67, 69, 74, 88, 77, 90, 72, 76, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] weixing3 = {80, 67, 84, 85, 75, 64, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};


        double henduan1;//代表每个学生的总分
        double henduan2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            henduan1 = weixing1[i] + weixing2[i] + weixing3[i];
//            henduan2= (henduan1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + henduan1);
//            System.out.println(name[i] + "的平均分为:" + henduan2);

        double peini1 = 0,peini2 = 0;
        double[] shijie = new double[30];
//        for (int i = 0; i < 30; i++) {
//            peini1= weixing1[i] + weixing2[i] + weixing3[i];
//            peini2 = (peini1* 1.0) / 3;
//            shijie[i] =peini2;
//        }
//
//        for (int i = 0; i < shijie.length - 1; i++) {
//            for (int j = 0; j < shijie.length - i - 1; j++) {
//                if (shijie [j] < shijie[j + 1]) {
//                    double tep = shijie[j];
//                    shijie[j] =shijie[j + 1];
//                    shijie[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(shijie[i]);
//        }

        double qingchun1 = 0, qingchun2 = 0, qingchun3 = 0;//计算每门课的平均分
        double make1 = 0, make2 = 0, make3 = 0;//计算每门课标准差
        double beacuse1 = 0,beacuse2 = 0, beacuse3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < weixing1.length; i++) {
            he += weixing1[i];
        }
        qingchun1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +qingchun1);
        double Sum = 0;
        for (int i = 0; i < weixing2.length; i++) {
            Sum += weixing2[i];
        }
        qingchun2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + qingchun2);
        double sum = 0;
        for (int i = 0; i < weixing3.length; i++) {
            sum +=weixing3[i];
        }
        qingchun3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + qingchun3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < weixing1.length; i++) {
            c1 += (weixing1[i] - qingchun1) * (weixing1[i] -qingchun1);
        }
        make1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + make1);
        for (int i = 0; i <weixing2.length; i++) {
            c2 += (weixing2[i] - qingchun2) * (weixing2[i] -qingchun2);
        }
        make2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +make2);

        for (int i = 0; i <weixing3.length; i++) {
            c3 += (weixing3[i] - qingchun3) * (weixing3[i] - qingchun3);
        }
        make3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +make3);
//////
//        Arrays.sort(weixing1);
//        Arrays.sort(weixing2);
//        Arrays.sort(weixing3);
//        beacuse1 = (weixing1[15] + weixing2[14]) * 1.0 / 2;
//        beacuse2 = (weixing2[15] +weixing2[14]) * 1.0 / 2;
//        beacuse3 = (weixing3[15] + weixing3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  beacuse1);
//        System.out.println("农业设施设计与制造的中位数为:" + beacuse2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + beacuse3);








    }
}
